package com.xueyi.operations.controller.admin;

import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.core.web.validate.V_A;
import com.xueyi.common.core.web.validate.V_E;
import com.xueyi.common.log.annotation.Log;
import com.xueyi.common.log.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import com.xueyi.operations.controller.base.BOpManufacturerTypeController;
import com.xueyi.operations.domain.dto.OpManufacturerTypeDto;
import com.xueyi.operations.domain.query.OpManufacturerTypeQuery;
import io.swagger.v3.oas.annotations.Operation;
import com.xueyi.common.security.annotation.AdminAuth;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 资产分类管理 | 管理端 业务处理
 *
 * @author xueyi
 */
@AdminAuth
@RestController
@RequestMapping("/admin/manufacturertype")
public class AOpManufacturerTypeController extends BOpManufacturerTypeController {

    @Override
    @GetMapping("/list")
    @Operation(summary = "查询资产分类列表")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturertype:list')")
    public AjaxResult list(OpManufacturerTypeQuery opManufacturerType) {
        return super.list(opManufacturerType);
    }

    @Override
    @GetMapping(value = "/{id}")
    @Operation(summary = "查询资产分类详细")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturertype:single')")
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return super.getInfo(id);
    }

    @Override
    @PostMapping
    @Operation(summary = "资产分类新增")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturertype:add')")
    @Log(title = "资产分类管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody OpManufacturerTypeDto opManufacturerType) {
        return super.add(opManufacturerType);
    }

    @Override
    @PutMapping
    @Operation(summary = "资产分类修改")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturertype:edit')")
    @Log(title = "资产分类管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody OpManufacturerTypeDto opManufacturerType) {
        return super.edit(opManufacturerType);
    }

    @Override
    @DeleteMapping("/batch/{idList}")
    @Operation(summary = "资产分类批量删除")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturertype:del')")
    @Log(title = "资产分类管理", businessType = BusinessType.DELETE)
    public AjaxResult batchRemove(@PathVariable List<Long> idList) {
        return super.batchRemove(idList);
    }
}
